//
//  WeddingCarDetailInfoCell.m
//  BaseProject
//
//  Created by 王洋 on 2021/5/13.
//  Copyright © 2021 王洋. All rights reserved.
//

#import "WeddingCarDetailInfoCell.h"

@implementation WeddingCarDetailInfoCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)layoutSubviews {
    [super layoutSubviews];
    
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.01 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        [self.intentionBtn pp_clipCorners:UIRectCornerAllCorners radius:self.intentionBtn.frame.size.height/2];
    });
}

- (void)fillCellWithModel:(CommonPackageModel *)model {
    self.model = model;
    
    self.packageNameLab.text = model.goodsName;    
    self.packagePriceLab.text = model.platformPriceArea;
    
    NSInteger depositType = self.model.sellerDeposit.depositType;
    double deposit = self.model.sellerDeposit.deposit;
    NSString *intention= @"";
    if (depositType == 1) {
        double dep = deposit*0.01;
        double goodsActivePrice = dep * model.goodsActivePrice;
        intention = [NSString stringWithFormat:@"意向金¥%@",[Utilities changeDoubleToString:goodsActivePrice]];
    } else {
        intention = [NSString stringWithFormat:@"意向金¥%@",[Utilities changeDoubleToString:deposit]];
    }
    [self.intentionBtn setTitle:intention forState:UIControlStateNormal];
    
    if (deposit == 0) {
        self.intentionBtn.hidden = YES;
    } else {
        self.intentionBtn.hidden = NO;
    }
    
    NSDictionary*attribtDic = @{NSStrikethroughStyleAttributeName: [NSNumber numberWithInteger:NSUnderlineStyleSingle]};
    NSMutableAttributedString*attribtStr = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"¥%@",[NSString stringWithFormat:@"市场价%@",model.marketPriceArea]] attributes:attribtDic];//
    
    self.packageLinePriceLab.attributedText = attribtStr;
    
}

+ (CGFloat)calculateHeightWithModel:(CommonPackageModel *)model{
    return 60 + [Utilities getStringHeightWithText:model.goodsName font:[UIFont systemFontOfSize:16 weight:UIFontWeightMedium] viewWidth:(TTScreenWidth - 28)] + 10;
}

@end
